<!--大小额贷记往账手工处理页面-->
<template>
  <div class="app-container">
    <h1>hd</h1>

    <Ht-search-form
      v-show="showSearch"
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      :beforeSearchCallback="false"
      @beforeSearchCallback="beforeSearchCallback"
      :clearCallBack="clearCallBack"
      :labelWidth="85"
    >
      <template slot="endSlotOption">
        <amount-range-search label="金额区间" ref="amountRangeSearch"></amount-range-search>
      </template>
    </Ht-search-form>
    <ht-table
      ref="dataTable"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="center" width="120" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  // permission: 'user:xxx:xxx',
                  doFunc: () => {
                    handleAction('details', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <!-- 明细操作弹出框 -->
    <nostro-setting111
      ref="nostroSettingDialog111"
      :dictMap="dictMap"
      :formData.sync="formData"
      @editComplete="editComplete"
    ></nostro-setting111>
    <nostro-setting112
      ref="nostroSettingDialog112"
      :dictMap="dictMap"
      :formData.sync="formData"
      @editComplete="editComplete"
    ></nostro-setting112>
    <nostro-setting121
      ref="nostroSettingDialog121"
      :dictMap="dictMap"
      :formData.sync="formData"
      @editComplete="editComplete"
    ></nostro-setting121>
    <nostro-setting122
      ref="nostroSettingDialog122"
      :dictMap="dictMap"
      :formData.sync="formData"
      @editComplete="editComplete"
    ></nostro-setting122>
    <nostro-setting115
      ref="nostroSettingDialog115"
      :dictMap="dictMap"
      :formData.sync="formData"
      @editComplete="editComplete"
    ></nostro-setting115>
  </div>
</template>
<script>
import {
  hvpsBepsCreditNostroQuery,
  hvpsBepsCreditNostroDetail,
} from "@/api/cnaps/beps/baseHandWork/hvpsBepsCreditVostroHdWk";
import NostroSetting111 from "./components/nostroSetting111";
import NostroSetting112 from "./components/nostroSetting112";
import NostroSetting121 from "./components/nostroSetting121";
import NostroSetting122 from "./components/nostroSetting122";
import NostroSetting115 from "./components/nostroSetting115";
import { listPageMixin } from "@/libs/listPageMixin";
import { log } from "util";
import { amountThousandsFormatter } from "@/utils/table_col_formatter";
import AmountRangeSearch from "@/views/components/AmountSearchInput";

export default {
  name: "HvpsBepsCreditNostroHdWk",
  mixins: [listPageMixin],
  components: {
    NostroSetting111,
    NostroSetting112,
    NostroSetting121,
    NostroSetting122,
    NostroSetting115,
    AmountRangeSearch,
  },
  data() {
    return {
      reqConfig: hvpsBepsCreditNostroQuery,
      formOptions: [],
      //数据字典
      searchFormDictList: [
        "NON_STP_TYPE",
        "SYSTEMCODE",
        "TXN_STATUS",
        "PRIORITY3CODE",
        "TXN_SOURCE",
        "CBFLAG",
        "PAY_TYPE",
        "BUDGETLEVELCODE",
        "INDICATOR_CODE",
        "BUDGETTYPECODE",
        "DEPT_CODE",
        "DEBT_BANK_TYPE",
      ],
      //  明细弹框数据
      // form表单字段
      formData: {
        data: {},
      },
      // 查询参数
      queryParams: {
        id: "",
        cpgdate: "",
        cpgdate2: "",
        workdate: "",
        workdate2: "",
        nstpRemarks: "",
        amount: "",
        amount2: "",
      },
      opButtonList: () => {
        return [];
      },
      tableBindColumns: [
        {
          label: `系统编号`,
          prop: "sysCode",
          dictCode: "SYSTEMCODE",
          sortable: false,
        },
        {
          label: `交易流水号`,
          prop: "id",
          width: "200",
          sortable: false,
        },
        {
          label: `CPG日期`,
          prop: "cpgdate",
          width: "150",
          sortable: false,
          type: "date",
        },
        {
          label: `工作日期`,
          prop: "workdate",
          width: "150",
          sortable: false,
          type: "date",
        },

        {
          label: `报文类型`,
          prop: "msgType",
          width: "200",
          sortable: false,
          formatter(row, text, index) {
            return (
              (row["msgType"] === null || row["msgType"] === undefined ? "" : row["msgType"]) +
              "-" +
              (row["msgTypeDesc"] === null || row["msgTypeDesc"] === undefined ? "" : row["msgTypeDesc"])
            );
          },
        },
        {
          label: `业务类型`,
          prop: "bizTypeCode",
          width: "200",
          sortable: false,
          formatter(row, text, index) {
            return (
              (row["bizTypeCode"] === null || row["bizTypeCode"] === undefined ? "" : row["bizTypeCode"]) +
              "-" +
              (row["bizTypeCodeDesc"] === null || row["bizTypeCodeDesc"] === undefined ? "" : row["bizTypeCodeDesc"])
            );
          },
        },
        {
          label: `业务状态`,
          prop: "bizStatus",
          width: "200",
          dictCode: "TXN_STATUS",
          sortable: false,
        },
        {
          label: `non-STP类型`,
          prop: "nstpType",
          width: "200",
          dictCode: "NON_STP_TYPE",
          sortable: false,
        },
      ],
    };
  },
  mounted() {
    this.$refs.amountRangeSearch.$on("getAmountRange", this.beforeSearchCallback);

    this.formOptions = [
      {
        type: "input",
        prop: "id",
        defaultAttr: {
          size: "small",
          label: "交易流水号",
          placeholder: "请输入交易流水号",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "cpgdate",
          endTimeName: "cpgdate2",
        },
        defaultAttr: {
          size: "small",
          label: "CPG日期",
          placeholder: ["请输入CPG日期开始", "请输入CPG日期结束"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
      {
        type: "dict",
        prop: "nstpRemarks",
        dict: "NON_STP_TYPE",
        defaultAttr: {
          size: "small",
          label: "non-STP原因",
          placeholder: "non-STP原因",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "workdate",
          endTimeName: "workdate2",
        },
        defaultAttr: {
          size: "small",
          label: "工作日期",
          placeholder: ["请输入工作日期开始", "请输入工作日期结束"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
    ];
  },
  methods: {
    beforeSearchCallback() {
      // 搜索按钮之前先执行
      this.queryParams.amount = this.$refs.amountRangeSearch.getAmount1();
      this.queryParams.amount2 = this.$refs.amountRangeSearch.getAmount2();
    },
    clearCallBack() {
      return new Promise((resolve, reject) => {
        that.$refs.amountRangeSearch.clearAmount();
        that.queryParams.amount = "";
        that.queryParams.amount2 = "";
      });
    },
    editComplete(state) {
      if (state == true) {
        this.$refs.dataTable.doQuery();
      }
    },
    handleAction(type, row = {}) {
      switch (type) {
        case "details":
          // 明细详情

          hvpsBepsCreditNostroDetail({ id: row.id, msgType: row.msgType, bizTypeCode: row.bizTypeCode }).then((res) => {
            this.formData = _.clone(res.result);
            if (row.msgType == "hvps.111.001.01") {
              this.$refs.nostroSettingDialog111.show();
            }
            if (row.msgType == "hvps.112.001.01") {
              this.$refs.nostroSettingDialog112.show();
            }
            if (row.msgType == "beps.121.001.01") {
              this.$refs.nostroSettingDialog121.show();
            }
            if (row.msgType == "beps.122.001.01") {
              this.$refs.nostroSettingDialog122.show();
            }
            if (row.msgType == "hvps.115.001.01") {
              this.$refs.nostroSettingDialog115.show();
            }
          });

          break;
      }
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}
</style>
